Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't throw exceptions on back-to-back window deactivations #23519

Merged
merged 3 commits into from
Jul 13, 2024

Conversation

Foda
Copy link
Member

@Foda Foda commented Jul 9, 2024

Description of Change

Don't throw exceptions on back-to-back window deactivations as this is valid behavior on platforms such as Windows (should we limit this change to just Windows?)

This is because it's possible to receive 2 "deactivate" window messages in a row if 2 child process windows are created rapidly. Each deactivate message has a parameter of the handle for the new window being created.

Issues Fixed

Fixes #22406

…is valid behavior on platforms such as Windows.
@Foda Foda requested a review from PureWeen July 9, 2024 22:47
@Foda Foda requested a review from a team as a code owner July 9, 2024 22:47
@Foda Foda requested a review from mattleibow July 9, 2024 22:47
@Foda Foda changed the title Don't throw exceptions on back-to-back window deactivations, as this … Don't throw exceptions on back-to-back window deactivations Jul 9, 2024
Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Activated ever get fired? Like, does activated fire once and deactivated is fired twice?

Or does the window just get created and deactivated is called twice?

Would a possible fix be to not even call deactivated at all on windows for this scenario?

Like, are these deactivate calls that come from the windows platform useful at all?

Just validating if we're fixing something here that should just be a platform specific modification vs an xplat one.

!_isActivated)
{
// Don't invoke deactivated event if we're not activated. It's possible we can
// recieve this event twice if we start more than one process at a time
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would two processes be using the same MauiWinUIWindow?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, they're not the same MauiWinUIWindow: starting any process that has a window will send a window message back to the window of the process that started it:
image

@PureWeen PureWeen enabled auto-merge (squash) July 12, 2024 17:30
@PureWeen PureWeen merged commit 79dd879 into main Jul 13, 2024
97 checks passed
@PureWeen PureWeen deleted the foda/WndActivation branch July 13, 2024 00:35
@FelixLorenz
Copy link

Thank you for adressing this!

@samhouts samhouts added fixed-in-net9.0-nightly This may be available in a nightly release! fixed-in-net8.0-nightly This may be available in a nightly release! fixed-in-8.0.80 and removed fixed-in-net9.0-nightly This may be available in a nightly release! fixed-in-net8.0-nightly This may be available in a nightly release! labels Aug 2, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash: Window was already deactivated
4 participants